package com.etoak.web;

import com.etoak.domain.Book;
import com.etoak.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.math.BigDecimal;
import java.util.Date;

/**
 * Description : 图书Controller
 * Author : buf
 * Date : 2018/9/6 16:35
 **/
@Controller
@RequestMapping("/book")
public class BookController {

    @Autowired
    private BookService bookService;

    @RequestMapping("/book_frame")
    public String book() {
        return "book_frame";
    }

    @RequestMapping("/insert_book")
    @ResponseBody
    public String insertBook() {
        Book book = new Book();
        book.setBookName("易途");
        book.setPrice(new BigDecimal(100.2));
        book.setCreateTime(new Date());
        bookService.insertBook(book);
        return "success";
    }
}
